package com.example.httpservlet;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GetPostTest {

    //无参get请求：http://localhost:7002/getnumber
    @GetMapping("/getnumber")
    public String addNum() {
        return "22";
    }

    //有参get请求：http://localhost:7002/calculator?a=1&b=2
    @GetMapping("/calculator")
    public int addNum(int a, int b) {
        return a + b;
    }

    //post请求
    @PostMapping("/submit")
    public int watchVideo(@RequestBody Student student) {
        return student.getA() + student.getB();
    }

}
